package c.m.d.b.beans;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import java.io.Serializable;

@Embeddable
//todo:implement the other things of key class
//todo: In the generated sql on delete cascade is not being generated for the property type for the foreign key.
public final class PropertyTypePK implements Serializable
{
    private static final long serialVersionUID = 1L;

    @Column(name = "ENTITY_TYPE_NAME", nullable = false)
    private String entityTypeName;

    @Column(name = "PROPERTY_TYPE_NAME", nullable = false)
    private String propertyTypeName;

    public String getEntityTypeName()
    {
        return entityTypeName;
    }

    public void setEntityTypeName(String entityTypeName)
    {
        this.entityTypeName = entityTypeName;
    }

    public String getPropertyTypeName()
    {
        return propertyTypeName;
    }

    public void setPropertyTypeName(String propertyTypeName)
    {
        this.propertyTypeName = propertyTypeName;
    }

    @Override
    public boolean equals(Object o)
    {
        if (this == o)
        {
            return true;
        }
        if (o == null || getClass() != o.getClass())
        {
            return false;
        }

        PropertyTypePK that = (PropertyTypePK) o;

        if (!entityTypeName.equals(that.entityTypeName))
        {
            return false;
        }
        if (!propertyTypeName.equals(that.propertyTypeName))
        {
            return false;
        }

        return true;
    }

    @Override
    public int hashCode()
    {
        int result = entityTypeName.hashCode();
        result = 31 * result + propertyTypeName.hashCode();
        return result;
    }
}
